/*
 * 类名称:TranferController.java
 * 包名称:com.platform.controller
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2019-10-13 23:57:17        lipengjun     初版做成
 *
 * Copyright (c) 2019-2019 微同科技
 */
package com.platform.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.annotation.SysLog;
import com.platform.entity.WxuserOrderEntity;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import com.platform.controller.AbstractController;
import com.platform.entity.TranferEntity;
import com.platform.service.TranferService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 申请提现记录表Controller
 *
 * @author lipengjun
 * @date 2019-10-13 23:57:17
 */
@RestController
@RequestMapping("tranfer")
public class TranferController extends AbstractController {
    @Autowired
    private TranferService tranferService;

    /**
     * 查看所有列表
     *
     * @param params 查询参数
     * @return R
     */
    @RequestMapping("/queryAll")
    @RequiresPermissions("tranfer:list")
    public R queryAll(@RequestParam Map<String, Object> params) {
        List<TranferEntity> list = tranferService.queryAll(params);

        return R.ok().put("list", list);
    }

    /**
     * 分页查询申请提现记录表
     *
     * @param params 查询参数
     * @return R
     */
    @GetMapping("/list")
    @RequiresPermissions("tranfer:list")
    public R list(@RequestParam Map<String, Object> params) {
        Query query = new Query(params);

        List<TranferEntity> tranferEntities = tranferService.queryList(query);
        int total = tranferService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(tranferEntities, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }

    /**
     * 根据主键查询详情
     *
     * @param id 主键
     * @return R
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("tranfer:info")
    public R info(@PathVariable("id") Integer id) {
        TranferEntity tranfer = tranferService.getById(id);

        return R.ok().put("tranfer", tranfer);
    }

    /**
     * 新增申请提现记录表
     *
     * @param tranfer tranfer
     * @return R
     */
    @SysLog("新增申请提现记录表")
    @RequestMapping("/save")
    @RequiresPermissions("tranfer:save")
    public R save(@RequestBody TranferEntity tranfer) {

        tranferService.add(tranfer);

        return R.ok();
    }

    /**
     * 修改申请提现记录表
     *
     * @param tranfer tranfer
     * @return R
     */
    @SysLog("修改申请提现记录表")
    @RequestMapping("/update")
    @RequiresPermissions("tranfer:update")
    public R update(@RequestBody TranferEntity tranfer) {

        tranferService.update(tranfer);

        return R.ok();
    }

    /**
     * 根据主键删除申请提现记录表
     *
     * @param ids ids
     * @return R
     */
    @SysLog("删除申请提现记录表")
    @RequestMapping("/delete")
    @RequiresPermissions("tranfer:delete")
    public R delete(@RequestBody Integer[] ids) {
        tranferService.deleteBatch(ids);

        return R.ok();
    }
}
